<?php
@session_start();
 $con = mysqli_connect("127.0.0.1","root","","posts");

 $content = $_POST['content'];
 $today = date("Y-m-d H:i:s");
 $name = $_SESSION['user'];
 
 $query = "select * from info where name='$name'";
 $result=mysqli_query($con,$query);
 $row = mysqli_fetch_row($result);
 
 mysqli_query($con,"INSERT INTO posts ( content, contentDate,name,avatar)
            VALUES ( '$content', '$today','$name','$row[1]')");
 
 
 mysqli_close($con);
 
 echo "<script>window.location='../html/posts.html'</script>";
?>